﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Expression.Encoder.Devices;
using Microsoft.Expression.Encoder.Live;
using Microsoft.Expression.Encoder;
using System.Runtime.InteropServices;


namespace WebCamDVR
{
    public partial class frmConfig : Form
    {
        LiveDeviceSource deviceSource;
        LiveDeviceSource deviceSource1;
        LiveDeviceSource deviceSource2;
        LiveDeviceSource deviceSource3;

        public frmConfig(LiveDeviceSource deviceSource, LiveDeviceSource deviceSource1, LiveDeviceSource deviceSource2,
            LiveDeviceSource deviceSource3)
        {
            InitializeComponent();
            this.deviceSource = deviceSource;
            this.deviceSource1 = deviceSource1;
            this.deviceSource2 = deviceSource2;
            this.deviceSource3 = deviceSource3;
            if (deviceSource == null)
            {
                btnCam0.Enabled = false;
                chkCam0.Enabled = false;
            }
            if (deviceSource1 == null)
            {
                btnCam1.Enabled = false;
                chkCam1.Enabled = false;
            }
            if (deviceSource2 == null)
            {
                btnCam2.Enabled = false;
                chkCam2.Enabled = false;
            }
            if (deviceSource3 == null)
            {
                btnCam3.Enabled = false;
                chkCam3.Enabled = false;
            }
                
        }

        private void btnSalir_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnCam0_Click(object sender, EventArgs e)
        {
            if (deviceSource.IsDialogSupported(ConfigurationDialog.VideoCaptureDialog))
            {
                deviceSource.ShowConfigurationDialog(ConfigurationDialog.VideoCaptureDialog, (new HandleRef(this, this.Handle)));
            }
        }

        private void btnCam1_Click(object sender, EventArgs e)
        {
            if (deviceSource1.IsDialogSupported(ConfigurationDialog.VideoCaptureDialog))
            {
                deviceSource1.ShowConfigurationDialog(ConfigurationDialog.VideoCaptureDialog, (new HandleRef(this, this.Handle)));
            }
        }

        private void btnCam2_Click(object sender, EventArgs e)
        {
            if (deviceSource2.IsDialogSupported(ConfigurationDialog.VideoCaptureDialog))
            {
                deviceSource2.ShowConfigurationDialog(ConfigurationDialog.VideoCaptureDialog, (new HandleRef(this, this.Handle)));
            }
        }

        private void btnCam3_Click(object sender, EventArgs e)
        {
            if (deviceSource3.IsDialogSupported(ConfigurationDialog.VideoCaptureDialog))
            {
                deviceSource3.ShowConfigurationDialog(ConfigurationDialog.VideoCaptureDialog, (new HandleRef(this, this.Handle)));
            }
        }

        private void btnExaminar_Click(object sender, EventArgs e)
        {
            if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
            {
                textBox1.Text = folderBrowserDialog1.SelectedPath;
            }
        }
    }
}
